﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
namespace ForceSynch
{
    class Helper
    {
        public static void CopyFile(string path1, string path2)
        {
            try
            {
                BinaryReader br = new BinaryReader(File.Open(path1, FileMode.Open, FileAccess.Read, FileShare.Read));
                BinaryWriter bw = new BinaryWriter(File.Open(path2, FileMode.Create, FileAccess.Write));
                while (br.BaseStream.Length != br.BaseStream.Position)
                {
                    bw.Write(br.ReadBytes(20480));
                }
                br.Close();
                bw.Close();
            }
            catch (Exception ex)
            {
                Trace.TraceError("Could not copy file: " + path1 + " to " + path2 + ". Exception: " + ex.ToString());
            }
        }
        public static int CompareDates(DateTime d1, DateTime d2)
        {
            if (d1 > d2 + new TimeSpan(0, 5, 0))
            {
                return -1;
            }
            if (d2>d1+new TimeSpan(0,5,0)){
                return 1;
            }
            return 0;
        }
    }
}
